import React from 'react';
// import ReactDOM from 'react-dom/client';
import ReactDOM from 'react-dom';
import 'antd/dist/antd.min.css';
import App from './App';
import './public-path';
import { HashRouter } from 'react-router-dom';
import reportWebVitals from './reportWebVitals';
import Local from '@/store';

function render(props) {
  const { container } = props;
  const root = container ? container.querySelector('#root') : document.getElementById('root');
  // const root = ReactDOM.createRoot(dom);
  ReactDOM.render(
    <React.StrictMode>
      <Local.Provider>
        <HashRouter basename={window.__POWERED_BY_QIANKUN__ ? '/react' : ''}>
          <App />
        </HashRouter>
      </Local.Provider>
    </React.StrictMode>,
    root
  );
}

if (!window.__POWERED_BY_QIANKUN__) {
  render({});
}

export async function bootstrap() {}

export async function mount(props) {
  console.log('react mount');
  render(props);
}

export async function unmount(props) {
  const { container } = props;
  ReactDOM.unmountComponentAtNode(container ? container.querySelector('#root') : document.querySelector('#root'));
}
// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
reportWebVitals();
